package com.example.bigevent.controller;

import com.example.bigevent.pojo.Review;
import com.example.bigevent.pojo.Result;
import com.example.bigevent.service.ReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/review")
public class ReviewController {
    @Autowired
    private ReviewService reviewService;

    @GetMapping("/game/{gameId}")
    public Result<List<Review>> getReviewsByGameId(@PathVariable Integer gameId) {
        List<Review> reviews = reviewService.getReviewsByGameId(gameId);
        return Result.success(reviews);
    }

    @PostMapping
    public Result addReview(@RequestBody Review review) {
        reviewService.addReview(review);
        return Result.success();
    }

    @DeleteMapping("/{reviewId}")
    public Result deleteReview(@PathVariable Integer reviewId) {
        reviewService.deleteReview(reviewId);
        return Result.success();
    }
}